import java.util.ArrayList;
import java.util.List;

abstract class Concretebuilder {
    abstract void BuildPart();
    abstract Product GetResult();
}

class Director {
    void Construct(Concretebuilder b){
        b.BuildPart();
    }
}
class Builder1 extends Concretebuilder {
    Product pro = new Product();
    public void BuildPart() {
        pro.add("AAA");
    }
    public Product GetResult() {
        return pro;
    }
}

class Builder2 extends Concretebuilder {
    Product pro = new Product();
    public void BuildPart() {
        pro.add("BBB");
    }
    public Product GetResult() {
        return pro;
    }
}

class Product {
    List<String> list = new ArrayList<String>();
    void add(String s)
    {
        list.add(s);
    }

    void show()
    {
        for(String s:list)
        {
            System.out.println("prd: "+s);
        }
    }
}
class test {
    public  static void main(String[] args) {
        Director d = new Director();
        Builder1 a = new Builder1();
        d.Construct(a);
        a.GetResult().show();

    
        Builder2 b = new Builder2();
        d.Construct(b);
        b.GetResult().show();
    }
}